﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Nuwa_created_man
{
    class Navy
    {
        public static Person GetPerson(String type) 
        {
            Person p = null;
            
            try
            {
                if (type=="m")
                {
                    p = new man();
                }
                else if(type=="w")
                {
                    p = new woman();
                }else if (type == "r")
                {
                    p = new robot();
                }
                else
                {
                    throw new noSuchPeopleException("只能生成这三类人");
                }
            }
            catch (noSuchPeopleException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return p;
        }
    }

    public class noSuchPeopleException : Exception
    {
        public noSuchPeopleException(){}
        public noSuchPeopleException(String massage,Exception innerExcption) : base(massage, innerExcption) { }
        public noSuchPeopleException(String massage) : base(massage) { }
    }
}
